package session

import (
	"fmt"
)

type UserActor struct {
	UserId int
	Actor  int
}

func GenGlobalActorRedisKey() string {
	return fmt.Sprintf("session:globalsession:actor")
}

func GetGlobalUserActor(userId int) (int, error) {
	//key := GenGlobalActorRedisKey()
	//REDIS

	//hget key userId

	return 0, nil
}

func SaveGlobalUserActor(userId, actor int) error {
	//key := GenGlobalActorRedisKey()
	//REDIS

	//hset key userId actor
	return nil
}

func GenGlobalUserRedisKey(userId int) string {
	return fmt.Sprintf("session:globalsession:userId:%v", userId)

}

func GetGlobalStudentSession(studentId int) *GlobalStudentSession {
	key := GenGlobalUserRedisKey(studentId)
	gs := &GlobalStudentSession{key: key, StudentId: studentId}
	gs.Load()
	return gs
}

func GetGlobalTeacherSession(teacherId int) *GlobalTeacherSession {
	return nil
}

//维护与redis通信
type GlobalStudentSession struct {
	key          string
	StudentId    int
	ClassId      int
	CourseId     int
	CourseType   int
	RoomId       string
	RoomOrder    int //进入房间次序
	OnlineStatus int
	SceneId      int //场景id
	SegId        int //环节id
}

func (ss *GlobalStudentSession) Init() {
	ss.CourseId = 0
	ss.RoomId = ""
	ss.RoomOrder = 0
	ss.SceneId = 0
	ss.SegId = 0
}

func (ss *GlobalStudentSession) Load() {

}

func (ss *GlobalStudentSession) Save() {

}

type GlobalTeacherSession struct {
	key       string
	TeacherId int
	ClassId   int
	CourseId  int
	RoomId    int
	SceneId   int
	SegId     int
}
